﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace WpfApp_Binding.BindingProperties
{
    public class GenderValueConvert : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if(value == null || parameter == null)
                throw new ArgumentNullException();
            int _value = int.Parse(value.ToString()!);
            int _param = int.Parse(parameter.ToString()!);
            if (_value == _param)
                return true;
            return false;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null || parameter == null)
                throw new ArgumentNullException();
            bool _value = bool.Parse(value.ToString()!);
            int _param = int.Parse(parameter.ToString()!);
            if (_value && _param == 0)
                return 0;
            return 1;
        }
    }
}
